home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_352 / treewalk / treewalk.fun < prev    next >
Text File  |  1992-05-06  |  2KB  |  45 lines

  1. Treewalk is a function that hands allows the caller to specify a
  2. function to be called for every file in a subtree of the AmigaDOS file
  3. system.  While it doesn't do anything special, it does do this walk
  4. without consuming any critical resources (other than non-stack
  5. memory), it does it robustly, and it does it correctly. Many commands
  6. that have their own, built-in tree traversal routines seem to fail in
  7. one of these three areas.
  8.  
  9. usage:
  10.  
  11. #include <treewalk.h>
  12. int treewalk(BPTR root, int (*visit)(BPTR, struct FileInfoBlock *), long flags) ;
  13.  
  14. root is a lock on the directory to root the tree walk. It is visited
  15. just like all the other directories.
  16.  
  17. visitfunc is called to "visit" a file or directory. Returns TREE_CONT
  18. or TREE_STOP to continue or stop the tree walk.
  19.  
  20. flags currently just specifies what order the tree walk is to happen
  21. in.
  22.  
  23. Treewalk itself returns TRUE if everything worked ok, FALSE if it aborted
  24. for some reason other than out of files or the users request (almost
  25. inevitably, this means "out of memory").
  26.  
  27. When called, treewalk visits all the directories in the tree at root.
  28. "Visiting" a directory means that it calls the visit function once
  29. with a lock on the directory about to be visited and a NULL fib
  30. pointer, and then once for each file in the directory with that same
  31. lock, and a fib for that specific file.
  32.  
  33. The order that the directories is visited is controlled via flags.
  34. Flags takes on one of three values: TREE_PRE, TREE_POST or TREE_BOTH.
  35. TREE_PRE specifies a preorder traversal of the tree, in which a
  36. directory is visited before it's children are visited. TREE_POST is a
  37. postorder traversal, in which a directory is visited after all it's
  38. children are visited. TREE_BOTH does both, meaning that all
  39. directories are visited twice. In this case, those that have
  40. no subdirectories are visited twice in succession.
  41.  
  42.     Copyright 1989, Mike W. Meyer
  43.     These files may be used and redistributed under the terms
  44.     found in the file LICENSE.
  45.